/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package bsc.war.populate;

import bsc.ejb.entity.*;
import bsc.ejb.entity.ScoreCardDimension;
import bsc.ejb.metadata.Comparation;
import bsc.war.delegate.DelegateBSC;
import bsc.war.factory.Factory;
import bsc.war.service.ScoreCardUtils;
import java.text.DateFormat;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.List;
import java.util.TimeZone;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.AbstractController;

/**
 *
 * @author luisZavaleta
 */
public class AdvancePopulate2 extends AbstractController {

    @Override
    protected ModelAndView handleRequestInternal(HttpServletRequest request,
            HttpServletResponse response) throws Exception {
        DelegateBSC delegate = (DelegateBSC) Factory.getBean("DelegateBSC");

        //Create a view

        ScoreView scoreView = (ScoreView) Factory.getBean("ScoreView");
        scoreView.setName("Vista de Enable");
        scoreView.setDescription("Vista que contiene los Scorecards de Enable");
        delegate.createScoreView(scoreView);

        //Create Map Scorecard
        Map mapScorecard = (Map) Factory.getBean("Map");
        mapScorecard.setName("Mapa de Finanzas");
        mapScorecard.setScoreview(scoreView);
        delegate.createMap(mapScorecard);


        scoreView.setScoreCard(mapScorecard);
        delegate.updateScoreView(scoreView);
        

        //Create Perspective Scorecard
        Perspective perspectiveScorecard = (Perspective) Factory.getBean("Perspective");
        perspectiveScorecard.setName("Perspectiva de Finanzas");
        delegate.createPerspective(perspectiveScorecard);

        //Create Objetive Scorecard
        Objective objectiveScorecard = (Objective) Factory.getBean("Objective");
        objectiveScorecard.setName("F1. Mejorar las utilidades de la empresa");
        delegate.createObjective(objectiveScorecard);








        //Create Perspective Scorecard

        //Settings of the KPI
        Settings setting = (Settings) Factory.getBean("Settings");
        setting.setType(Settings.Type.SCORECARD);
        setting.setMathOperation("C/P");

        //Populate a new KPI
        Pointer pointer = (Pointer) Factory.getBean("Pointer");
        pointer.setName("F1.1 Ventas Netas");
        pointer.setDescription("Indicador de prueba");



        delegate.createPointer(pointer);

        //Populate a new Dimension
        Dimension dimension = (Dimension) Factory.getBean("Dimension");
        dimension.setName("Region");
        delegate.createDimension(dimension);

        //Populate a new Member
        DimensionMember dimensionmember1 = (DimensionMember) Factory.getBean("DimensionMember");
        dimensionmember1.setName("TOTAL_REGION");
        dimensionmember1.setDimension(dimension);
        delegate.createDimensionMember(dimensionmember1);

        DimensionMember dimensionmember2 = (DimensionMember) Factory.getBean("DimensionMember");
        dimensionmember2.setName("MX");
        dimensionmember2.setDimension(dimension);
        dimensionmember2.setDimensionMember(dimensionmember1);
        delegate.createDimensionMember(dimensionmember2);

        DimensionMember dimensionmember3 = (DimensionMember) Factory.getBean("DimensionMember");
        dimensionmember3.setName("CR");
        dimensionmember3.setDimension(dimension);
        dimensionmember3.setDimensionMember(dimensionmember1);
        delegate.createDimensionMember(dimensionmember3);


        //Populate a new IndDim
        ScoreCardDimension scorecarddimension = (ScoreCardDimension) Factory.getBean("ScoreCardDimension");
        scorecarddimension.setScoreCard(pointer);
        scorecarddimension.setDimension(dimension);
        delegate.createScoreCardDimension(scorecarddimension);

        //CreateComparation
        Comparation comparationReal = (Comparation) Factory.getBean("Comparation");
        comparationReal.setName("Real");
        comparationReal.setType(Comparation.Type.REAL);

        Comparation comparationGoal = (Comparation) Factory.getBean("Comparation");
        comparationGoal.setName("Meta");
        comparationGoal.setType(Comparation.Type.GOAL);

        delegate.createComparation(comparationReal);
        delegate.createComparation(comparationGoal);


        //Populate a new Comparador Real
        Comparator comparatorR = (Comparator) Factory.getBean("Comparator");
        comparatorR.setDescription("Real");
        comparatorR.setComparation(comparationReal);
        comparatorR.setPointer(pointer);
        delegate.createComparator(comparatorR);

        //Populate a new Comparador Meta
        Comparator comparatorM = (Comparator) Factory.getBean("Comparator");
        comparatorM.setDescription("Meta");
        comparatorM.setComparation(comparationGoal);
        comparatorM.setPointer(pointer);
        delegate.createComparator(comparatorM);

        //Populate DimensionalCut
        DimensionalCut dimensionalcut1 = (DimensionalCut) Factory.getBean("DimensionalCut");
        dimensionalcut1.setPointer(pointer);
        dimensionalcut1.setType(DimensionalCut.Type.TOTAL);
        delegate.createDimensionalCut(dimensionalcut1);

        DimensionalCut dimensionalcut2 = (DimensionalCut) Factory.getBean("DimensionalCut");
        dimensionalcut2.setPointer(pointer);
        dimensionalcut2.setType(DimensionalCut.Type.STANDARD);
        delegate.createDimensionalCut(dimensionalcut2);

        DimensionalCut dimensionalcut3 = (DimensionalCut) Factory.getBean("DimensionalCut");
        dimensionalcut3.setPointer(pointer);
        dimensionalcut3.setType(DimensionalCut.Type.STANDARD);
        delegate.createDimensionalCut(dimensionalcut3);

        //Populate DimensionalCut-DimensionalMember
        DimensionalCutMember dcm = (DimensionalCutMember) Factory.getBean("DimensionalCutMember");
        dcm.setDimensionMember(dimensionmember1);
        dcm.setDimensionalCut(dimensionalcut1);
        delegate.createDimensionalCutMember(dcm);

        DimensionalCutMember dcm2 = (DimensionalCutMember) Factory.getBean("DimensionalCutMember");
        dcm2.setDimensionMember(dimensionmember2);
        dcm2.setDimensionalCut(dimensionalcut2);
        delegate.createDimensionalCutMember(dcm2);

        DimensionalCutMember dcm3 = (DimensionalCutMember) Factory.getBean("DimensionalCutMember");
        dcm3.setDimensionMember(dimensionmember3);
        dcm3.setDimensionalCut(dimensionalcut3);
        delegate.createDimensionalCutMember(dcm3);

        //Time to EA
        DateFormat dfm = new SimpleDateFormat("yyyy-MM-dd");
        Calendar calendar = new GregorianCalendar();
        TimeZone timeZone = calendar.getTimeZone();
        dfm.setTimeZone(timeZone);

        List<Date> dates = ScoreCardUtils.generateDates(ScoreCardUtils.getLastDate(),1);
        for (Date date : dates) {
            Double realRoot= 0D;
            Double goalRoot= 0D;

            //Populate ComparatorDimensionalCut - MX
            ComparatorDimensionalCut cdc5 = (ComparatorDimensionalCut) Factory.getBean("ComparatorDimensionalCut");
            cdc5.setComparator(comparatorR);
            cdc5.setDimensionalCut(dimensionalcut2);
            cdc5.setRegisterDate(date);
            Double num=ScoreCardUtils.createRandomNumber();
            realRoot+=num;
            cdc5.setRegister(num);
            delegate.createComparatorDimensionalCut(cdc5);

            ComparatorDimensionalCut cdc6 = (ComparatorDimensionalCut) Factory.getBean("ComparatorDimensionalCut");
            cdc6.setComparator(comparatorM);
            cdc6.setDimensionalCut(dimensionalcut2);
            cdc6.setRegisterDate(date);
            num=ScoreCardUtils.createRandomNumber();
            goalRoot+=num;
            cdc6.setRegister(num);
            delegate.createComparatorDimensionalCut(cdc6);

            //Populate ComparatorDimensionalCut - CR
            ComparatorDimensionalCut cdc3 = (ComparatorDimensionalCut) Factory.getBean("ComparatorDimensionalCut");
            cdc3.setComparator(comparatorR);
            cdc3.setDimensionalCut(dimensionalcut3);
            cdc3.setRegisterDate(date);
            num=ScoreCardUtils.createRandomNumber();
            realRoot+=num;
            cdc3.setRegister(num);
            delegate.createComparatorDimensionalCut(cdc3);

            ComparatorDimensionalCut cdc4 = (ComparatorDimensionalCut) Factory.getBean("ComparatorDimensionalCut");
            cdc4.setComparator(comparatorM);
            cdc4.setDimensionalCut(dimensionalcut3);
            cdc4.setRegisterDate(date);
            num=ScoreCardUtils.createRandomNumber();
            goalRoot+=num;
            cdc4.setRegister(num);
            delegate.createComparatorDimensionalCut(cdc4);


            //Populate ComparatorDimensionalCut - TOTAL REGION

            ComparatorDimensionalCut cdc = (ComparatorDimensionalCut) Factory.getBean("ComparatorDimensionalCut");
            cdc.setComparator(comparatorR);
            cdc.setDimensionalCut(dimensionalcut1);
            cdc.setRegisterDate(date);
            cdc.setRegister(realRoot);
            delegate.createComparatorDimensionalCut(cdc);

            ComparatorDimensionalCut cdc2 = (ComparatorDimensionalCut) Factory.getBean("ComparatorDimensionalCut");
            cdc2.setComparator(comparatorM);
            cdc2.setDimensionalCut(dimensionalcut1);
            cdc2.setRegisterDate(date);
            cdc2.setRegister(goalRoot);
            delegate.createComparatorDimensionalCut(cdc2);

        }

        //-----------------------------------INDICADOR 2--------------------------------//
        //Populate a new KPI
        Pointer pointer2 = (Pointer) Factory.getBean("Pointer");
        pointer2.setName("F1.2 Gastos");
        pointer2.setDescription("Indicador de prueba");

        delegate.createPointer(pointer2);


        //Populate a new IndDim
        ScoreCardDimension scorecarddimension2 = (ScoreCardDimension) Factory.getBean("ScoreCardDimension");
        scorecarddimension2.setScoreCard(pointer2);
        scorecarddimension2.setDimension(dimension);
        delegate.createScoreCardDimension(scorecarddimension2);



        //Populate a new Comparador Real
        Comparator comparatorR2 = (Comparator) Factory.getBean("Comparator");
        comparatorR2.setDescription("Real");
        comparatorR2.setComparation(comparationReal);
        comparatorR2.setPointer(pointer2);
        delegate.createComparator(comparatorR2);

        //Populate a new Comparador Meta
        Comparator comparatorM2 = (Comparator) Factory.getBean("Comparator");
        comparatorM2.setDescription("Meta");
        comparatorM2.setComparation(comparationGoal);
        comparatorM2.setPointer(pointer2);
        delegate.createComparator(comparatorM2);

        //Populate DimensionalCut
        DimensionalCut dimensionalcut1_2 = (DimensionalCut) Factory.getBean("DimensionalCut");
        dimensionalcut1_2.setPointer(pointer2);
        dimensionalcut1_2.setType(DimensionalCut.Type.TOTAL);
        delegate.createDimensionalCut(dimensionalcut1_2);

        DimensionalCut dimensionalcut2_2 = (DimensionalCut) Factory.getBean("DimensionalCut");
        dimensionalcut2_2.setPointer(pointer2);
        dimensionalcut2_2.setType(DimensionalCut.Type.STANDARD);
        delegate.createDimensionalCut(dimensionalcut2_2);

        DimensionalCut dimensionalcut3_2 = (DimensionalCut) Factory.getBean("DimensionalCut");
        dimensionalcut3_2.setPointer(pointer2);
        dimensionalcut3_2.setType(DimensionalCut.Type.STANDARD);
        delegate.createDimensionalCut(dimensionalcut3_2);

        //Populate DimensionalCut-DimensionalMember
        DimensionalCutMember dcm_2 = (DimensionalCutMember) Factory.getBean("DimensionalCutMember");
        dcm_2.setDimensionMember(dimensionmember1);
        dcm_2.setDimensionalCut(dimensionalcut1_2);
        delegate.createDimensionalCutMember(dcm_2);

        DimensionalCutMember dcm2_2 = (DimensionalCutMember) Factory.getBean("DimensionalCutMember");
        dcm2_2.setDimensionMember(dimensionmember2);
        dcm2_2.setDimensionalCut(dimensionalcut2_2);
        delegate.createDimensionalCutMember(dcm2_2);

        DimensionalCutMember dcm3_2 = (DimensionalCutMember) Factory.getBean("DimensionalCutMember");
        dcm3_2.setDimensionMember(dimensionmember3);
        dcm3_2.setDimensionalCut(dimensionalcut3_2);
        delegate.createDimensionalCutMember(dcm3_2);

        //Time to EA
        DateFormat dfm2 = new SimpleDateFormat("yyyy-MM-dd");
        Calendar calendar2 = new GregorianCalendar();
        TimeZone timeZone2 = calendar2.getTimeZone();
        dfm2.setTimeZone(timeZone2);

        List<Date> dates_2 = ScoreCardUtils.generateDates(ScoreCardUtils.getLastDate(),1);
        for (Date date : dates_2) {
            Double realRoot = 0D;
            Double goalRoot = 0D;

            //Populate ComparatorDimensionalCut - MX
            ComparatorDimensionalCut cdc5 = (ComparatorDimensionalCut) Factory.getBean("ComparatorDimensionalCut");
            cdc5.setComparator(comparatorR2);
            cdc5.setDimensionalCut(dimensionalcut2_2);
            cdc5.setRegisterDate(date);
            Double num = ScoreCardUtils.createRandomNumber();
            realRoot += num;
            cdc5.setRegister(num);
            delegate.createComparatorDimensionalCut(cdc5);

            ComparatorDimensionalCut cdc6 = (ComparatorDimensionalCut) Factory.getBean("ComparatorDimensionalCut");
            cdc6.setComparator(comparatorM2);
            cdc6.setDimensionalCut(dimensionalcut2_2);
            cdc6.setRegisterDate(date);
            num = ScoreCardUtils.createRandomNumber();
            goalRoot += num;
            cdc6.setRegister(num);
            delegate.createComparatorDimensionalCut(cdc6);

            //Populate ComparatorDimensionalCut - CR
            ComparatorDimensionalCut cdc3 = (ComparatorDimensionalCut) Factory.getBean("ComparatorDimensionalCut");
            cdc3.setComparator(comparatorR2);
            cdc3.setDimensionalCut(dimensionalcut3_2);
            cdc3.setRegisterDate(date);
            num = ScoreCardUtils.createRandomNumber();
            realRoot += num;
            cdc3.setRegister(num);
            delegate.createComparatorDimensionalCut(cdc3);

            ComparatorDimensionalCut cdc4 = (ComparatorDimensionalCut) Factory.getBean("ComparatorDimensionalCut");
            cdc4.setComparator(comparatorM2);
            cdc4.setDimensionalCut(dimensionalcut3_2);
            cdc4.setRegisterDate(date);
            num = ScoreCardUtils.createRandomNumber();
            goalRoot += num;
            cdc4.setRegister(num);
            delegate.createComparatorDimensionalCut(cdc4);


            //Populate ComparatorDimensionalCut - TOTAL REGION

            ComparatorDimensionalCut cdc = (ComparatorDimensionalCut) Factory.getBean("ComparatorDimensionalCut");
            cdc.setComparator(comparatorR2);
            cdc.setDimensionalCut(dimensionalcut1_2);
            cdc.setRegisterDate(date);
            cdc.setRegister(realRoot/2);
            delegate.createComparatorDimensionalCut(cdc);

            ComparatorDimensionalCut cdc2 = (ComparatorDimensionalCut) Factory.getBean("ComparatorDimensionalCut");
            cdc2.setComparator(comparatorM2);
            cdc2.setDimensionalCut(dimensionalcut1_2);
            cdc2.setRegisterDate(date);
            cdc2.setRegister(goalRoot/2);
            delegate.createComparatorDimensionalCut(cdc2);

        }

        //Create Project
        Project project = (Project) Factory.getBean("Project");
        project.setName("Proyeto de Finanzas");
        delegate.createProject(project);

        Tracer tracerBudget = (Tracer) Factory.getBean("Tracer");
        tracerBudget.setName("Presupuesto");
        tracerBudget.setPercentFactor(.5);
        tracerBudget.setType(Tracer.Type.BUDGET);
        tracerBudget.setProject(project);
        delegate.createTracer(tracerBudget);

        Tracer tracerProgress = (Tracer) Factory.getBean("Tracer");
        tracerProgress.setName("Alcance");
        tracerProgress.setPercentFactor(.5);
        tracerProgress.setType(Tracer.Type.PROGRESS);
        tracerProgress.setProject(project);
        delegate.createTracer(tracerProgress);


        
        //Create Label
        Label label = (Label) Factory.getBean("Label");
        label.setName("Hito Proyecto");
        label.setProject(project);
        label.setRoot(Boolean.TRUE);
        delegate.createLabel(label);

  


        //Create Milestone 1 of the label 1
        Milestone milestone = (Milestone) Factory.getBean("Milestone");
        milestone.setName("Hito 1");
        //Fecha de Febrero
        milestone.setBeginDate(ScoreCardUtils.getMinimumDateMonth(1));
        //Fecha de Marzo
        milestone.setEndDate(ScoreCardUtils.getMinimumDateMonth(2));
        milestone.setTask(label);
        milestone.setProject(project);
        milestone.setRoot(Boolean.FALSE);
        delegate.createMilestone(milestone);


        //Create Milestone 2 of the label 1
        Milestone milestone2 = (Milestone) Factory.getBean("Milestone");
        milestone2.setName("Hito 2");
        //Fecha de Marzo
        milestone2.setBeginDate(ScoreCardUtils.getMinimumDateMonth(2));
        //Fecha de Agosto
        milestone2.setEndDate(ScoreCardUtils.getMinimumDateMonth(7));
        milestone2.setTask(label);
        milestone2.setProject(project);
        milestone2.setRoot(Boolean.FALSE);
        delegate.createMilestone(milestone2);

        //Create Label 2 of the label 1
        Label label2 = (Label) Factory.getBean("Label");
        label2.setName("Hito 3");
        label2.setTask(label);
        label2.setProject(project);
        label2.setRoot(Boolean.FALSE);
        delegate.createLabel(label2);

        //Create milestone 1 of the label 2
        Milestone milestone3 = (Milestone) Factory.getBean("Milestone");
        milestone3.setName("Hito 3.1");
        //Fecha de Abril
        milestone3.setBeginDate(ScoreCardUtils.getMinimumDateMonth(3));
        //Fecha de Sep
        milestone3.setEndDate(ScoreCardUtils.getMinimumDateMonth(8));
        milestone3.setTask(label2);
        milestone3.setProject(project);
        milestone3.setRoot(Boolean.FALSE);
        delegate.createMilestone(milestone3);

        //Create milestone 2 of the label 2
        Milestone milestone4 = (Milestone) Factory.getBean("Milestone");
        milestone4.setName("Hito 3.2");
        //Fecha de Abril
        milestone4.setBeginDate(ScoreCardUtils.getMinimumDateMonth(3));
        //Fecha de Sep
        milestone4.setEndDate(ScoreCardUtils.getMinimumDateMonth(8));
        milestone4.setTask(label2);
        milestone4.setProject(project);
        milestone4.setRoot(Boolean.FALSE);
        delegate.createMilestone(milestone4);



        //MileStone 1 Tracer Progress
        MilestoneTracer milestoneTracer1 = (MilestoneTracer) Factory.getBean("MilestoneTracer");
        milestoneTracer1.setMilestone(milestone);
        milestoneTracer1.setTracer(tracerProgress);
        milestoneTracer1.setRealValue(.5);

        //MileStone 1 Tracer Budget
        MilestoneTracer milestoneTracer2 = (MilestoneTracer) Factory.getBean("MilestoneTracer");
        milestoneTracer2.setMilestone(milestone);
        milestoneTracer2.setTracer(tracerBudget);
        milestoneTracer2.setRealValue(.5);
        milestoneTracer2.setGoalValue(1D);

        //MileStone 2 Tracer Progress
        MilestoneTracer milestoneTracer3 = (MilestoneTracer) Factory.getBean("MilestoneTracer");
        milestoneTracer3.setMilestone(milestone2);
        milestoneTracer3.setTracer(tracerProgress);
        milestoneTracer3.setRealValue(.5);

        //MileStone 2 Tracer Budget
        MilestoneTracer milestoneTracer4 = (MilestoneTracer) Factory.getBean("MilestoneTracer");
        milestoneTracer4.setMilestone(milestone2);
        milestoneTracer4.setTracer(tracerBudget);
        milestoneTracer4.setRealValue(.5);
        milestoneTracer4.setGoalValue(1D);

        //MileStone 3 Tracer Progress
        MilestoneTracer milestoneTracer5 = (MilestoneTracer) Factory.getBean("MilestoneTracer");
        milestoneTracer5.setMilestone(milestone3);
        milestoneTracer5.setTracer(tracerProgress);
        milestoneTracer5.setRealValue(.5);

        //MileStone 3 Tracer Budget
        MilestoneTracer milestoneTracer6 = (MilestoneTracer) Factory.getBean("MilestoneTracer");
        milestoneTracer6.setMilestone(milestone3);
        milestoneTracer6.setTracer(tracerBudget);
        milestoneTracer6.setRealValue(.5);
        milestoneTracer6.setGoalValue(1D);



        //MileStone 4 Tracer Progress
        MilestoneTracer milestoneTracer7 = (MilestoneTracer) Factory.getBean("MilestoneTracer");
        milestoneTracer7.setMilestone(milestone4);
        milestoneTracer7.setTracer(tracerProgress);
        milestoneTracer7.setRealValue(.5);

        //MileStone 4 Tracer Budget
        MilestoneTracer milestoneTracer8 = (MilestoneTracer) Factory.getBean("MilestoneTracer");
        milestoneTracer8.setMilestone(milestone4);
        milestoneTracer8.setTracer(tracerBudget);
        milestoneTracer8.setRealValue(.5);
        milestoneTracer8.setGoalValue(1D);


        delegate.createMilestoneTracer(milestoneTracer1);
        delegate.createMilestoneTracer(milestoneTracer2);
        delegate.createMilestoneTracer(milestoneTracer3);
        delegate.createMilestoneTracer(milestoneTracer4);
        delegate.createMilestoneTracer(milestoneTracer5);
        delegate.createMilestoneTracer(milestoneTracer6);
        delegate.createMilestoneTracer(milestoneTracer7);
        delegate.createMilestoneTracer(milestoneTracer8);



        //Create ScorecardRelation
        ScoreCardRelation scoreCardRelation1 = (ScoreCardRelation) Factory.getBean("ScoreCardRelation");
        scoreCardRelation1.setScoreCard(mapScorecard);
        scoreCardRelation1.setOtherScoreCard(perspectiveScorecard);
        scoreCardRelation1.setPercentFactor(1D);
        delegate.createScoreCardRelation(scoreCardRelation1);

        ScoreCardRelation scoreCardRelation2 = (ScoreCardRelation) Factory.getBean("ScoreCardRelation");
        scoreCardRelation2.setScoreCard(perspectiveScorecard);
        scoreCardRelation2.setOtherScoreCard(objectiveScorecard);
        scoreCardRelation2.setPercentFactor(1D);
        delegate.createScoreCardRelation(scoreCardRelation2);

        ScoreCardRelation scoreCardRelation3 = (ScoreCardRelation) Factory.getBean("ScoreCardRelation");
        scoreCardRelation3.setScoreCard(objectiveScorecard);
        scoreCardRelation3.setOtherScoreCard(pointer);
        scoreCardRelation3.setPercentFactor(.333D);
        delegate.createScoreCardRelation(scoreCardRelation3);

        ScoreCardRelation scoreCardRelation4 = (ScoreCardRelation) Factory.getBean("ScoreCardRelation");
        scoreCardRelation4.setScoreCard(objectiveScorecard);
        scoreCardRelation4.setOtherScoreCard(pointer2);
        scoreCardRelation4.setPercentFactor(.333D);
        delegate.createScoreCardRelation(scoreCardRelation4);

        ScoreCardRelation scoreCardRelation5 = (ScoreCardRelation) Factory.getBean("ScoreCardRelation");
        scoreCardRelation5.setScoreCard(objectiveScorecard);
        scoreCardRelation5.setOtherScoreCard(project);
        scoreCardRelation5.setPercentFactor(.333D);
        delegate.createScoreCardRelation(scoreCardRelation5);

        //request.setAttribute("mapScorecard", mapScorecard);


        //Create a Person
        Person person = (Person) Factory.getBean("Person");
        person.setUsername("demouser");
        person.setPassword("demouser");
        delegate.createPerson(person);


        //Creo notas
        Note note = (Note)Factory.getBean("Note");
        note.setTitle("Note 1");
        note.setNote("Esta es una nota de prueba");
        note.setNoteDate(ScoreCardUtils.getLastDate());
        note.setScoreCard(mapScorecard);
        delegate.createNote(note);;


        return new ModelAndView("advancePopulate");
    }
}
